function [regressor_var_names]=check_dependent_and_regressors_for_consistency(dependent_var_names,regressor_var_names,spread_name,log_spread_dummy,firstdiff_spread_dummy)
% Copyright (C) 2014-19 Benjamin Born and Johannes Pfeifer 
%
% This is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This code is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% For a copy of the licencse,
% see <http://www.gnu.org/licenses/>.

spread_pos_candidates=strfind(dependent_var_names','spread');
if log_spread_dummy
    regressor_var_names=[regressor_var_names,['log_',spread_name]];
    if isempty(find(~cellfun(@isempty,spread_pos_candidates)))
        error('No spread variable found')
    else
        if ~strcmp(dependent_var_names{find(~cellfun(@isempty,spread_pos_candidates))},['log_',spread_name])
            error('Dependent variable for spread does not match indicator')
        end
    end
elseif firstdiff_spread_dummy
    regressor_var_names=[regressor_var_names,['first_diff_',spread_name]];
    if isempty(find(~cellfun(@isempty,spread_pos_candidates)))
        error('No spread variable found')
    else
        if ~strcmp(dependent_var_names{find(~cellfun(@isempty,spread_pos_candidates))},['first_diff_',spread_name])
            error('Dependent variable for spread does not match indicator')
        end
    end
else
    regressor_var_names=[regressor_var_names,spread_name];
%     if isempty(find(~cellfun(@isempty,spread_pos_candidates)))
%         error('No spread variable found')
%     else
%         if ~strcmp(dependent_var_names{find(~cellfun(@isempty,spread_pos_candidates))},spread_name)
%             error('Dependent variable for spread does not match indicator')
%         end
%     end
end
